//
//  RestaurantParty.m
//  MobileAppsTipApp
//
//  Created by jcotter on 10/10/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "RestaurantParty.h"


@implementation RestaurantParty


-(void)addGuest: (Guest*)newGuest
{
    [guests addObject:newGuest];
}
-(void)removeGuest: (Guest*)remGuest
{
    [guests removeObject:remGuest];
}
-(void)removeGuestAt: (int)index
{
    [guests removeObjectAtIndex: index];
}
-(double)getPartySubTotal
{
    double total = 0;
    for(int i = 0; i < [guests count]; i++)
    {
        Guest* g = [guests objectAtIndex:i];
        total += [g getSubtotal];
    }
    return total;
    
}
//Calculated from guest amounts
-(double)getPartyTotal
{
    double total = 0;
    for(int i = 0; i < [guests count]; i++)
    {
        Guest* g = [guests objectAtIndex:i];
        total += [g getTotal];
    }
    return total;
        
}
-(double)getPartyTipTotal
{
    double total = 0;
    for(int i = 0; i < [guests count]; i++)
    {
        Guest* g = [guests objectAtIndex:i];
        total += [g getTipTotal];
    }
    return total;
}

//Guest values
-(double)getGuestSubtotal: (int)index
{
    Guest* g = [guests objectAtIndex:index];
    return [g getSubtotal];
}
-(void)setGuestSubtotal: (int)index : (double)subtotal
{
    Guest* g = [guests objectAtIndex:index];
    [g setSubtotal:subtotal];
}
-(double)getGuestTipPerc: (int)index
{
    Guest* g = [guests objectAtIndex:index];
    return [g getTipPerc];
}
-(void)setGuestTipPerc: (int)index : (double)tipperc
{
    Guest* g = [guests objectAtIndex:index];
    [g setTipPerc:tipperc];
}
-(NSString*)getGuestName: (int)index
{
    return [guests objectAtIndex: index];
}
-(void)setGuestName: (int) index : (NSString*)name
{
    Guest* g = [guests objectAtIndex:index];
    [g settName: name];
}


@end
